#include<bits/stdc++.h>
using namespace std;
int n,a[200005],rt[200005],lt[200005],cnt;
void insert_right(int p,int q)//q->p
{
	rt[p]=rt[q];
	lt[p]=q;
	lt[rt[q]]=p;
	rt[q]=p;
}
void del(int x){
	rt[lt[x]]=rt[x];
	lt[rt[x]]=lt[x];
	rt[x]=lt[x]=-1;
}
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	cnt=n;
	rt[0]=n+1;
	a[0]=a[n+1]=-1;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		insert_right(i,i-1);
	}
	/*del(1),del(2);
	int nxt=rt[0];
	while(nxt!=n+1){
		cout<<a[nxt]<<' ';
		nxt=rt[nxt];
	}*/
	while(cnt>0){
		int nxt=rt[0],s=-1;
		while(nxt!=n+1){
			if(a[nxt]!=s){
				s=a[nxt];
				int t=nxt;
				nxt=rt[nxt];
				printf("%d ",t);
				del(t);
				cnt--;
			}
			else nxt=rt[nxt];
		}
		puts("");
	}
	
	return 0;
}
